public class User implements Comparable{
    public User(String username, int age) {
        this.username = username;
        this.age = age;
    }

    private String username;
    private int age;


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        User user = (User) o;

        if (age != user.age) return false;
        return username != null ? username.equals(user.username) : user.username == null;
    }

    @Override
    public int hashCode() {
        return username != null ? username.hashCode() : 0;
    }

    @Override
    public String toString() {
        return "User{" +
                "username='" + username + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public int compareTo(Object o) {
        User user = (User) o;

        if(this.age>user.age){
            return 1;
        }else if(this.age<user.age){
            return -1;
        }else{
            return 0;
        }


    }
}